#!/usr/bin/env python
# -*- coding: latin-1; py-indent-offset:4 -*-
################################################################################
# 
# This file is part of Bfplusplus
#
# Bfplusplus is a graphical interface to the Betfair Betting Exchange
# Copyright (C) 2010 Daniel Rodriguez (aka Daniel Rodriksson)
# Copyright (C) 2011 Sensible Odds Ltd.
#
# You can learn more and contact the author at:
#
#    http://code.google.com/p/bfplusplus/
#
# Bfplusplus is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Bfplusplus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Bfplusplus. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
"""Subclass of EditString, which is generated by wxFormBuilder."""

import wx

import MainGui

# Implementing EditString
class EditString(MainGui.EditString):

    def __init__(self, parent, value='', valueType=None):
	MainGui.EditString.__init__(self, parent)
        self.value = value
	self.m_textCtrlString.SetValue(value)
        self.valueType = valueType

    def OnOKButtonClick(self, event):
        self.value = self.m_textCtrlString.GetValue()

        if self.valueType is not None:
            try:
                value = self.valueType(self.value)
            except:
                wx.MessageBox('The introduced data is not valid',
                              'Wrong value')
                return

        self.EndModal(wx.ID_OK)
